#include <54func.h>
int main()
{
    //利用pipe实现全双工通信，重点在于：先open在fork会实现共享文件描述符的效果
    int fds1[2],fds2[2];
    pipe(fds1);
    pipe(fds2);

    if(fork())
    {
        close(fds1[0]);
        close(fds2[1]);
        write(fds1[1],"nihao,I am parent!",18);
        char buf[4096] = {0};
        read(fds2[0],buf,sizeof(buf));
        printf("Parent：buf = %s\n",buf);
    }else{
        close(fds1[1]);
        close(fds2[0]);
        write(fds2[1],"wofeichanghao!,I am child!\n",26);
        char buf[4096] = {0};
        read(fds1[0],buf,sizeof(buf));
        printf("Child：buf = %s\n",buf);

    }
    return 0;
}
